﻿using BussinessEntity;
using DataAccessLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utilities;

namespace BussinessLayer
{
    public class ReceiptManager
    {
        private static ReceiptDA adapter = new ReceiptDA();

        public static ActionResult<Receipt> Insert(Receipt entity)
        {
            return adapter.Insert(entity);
        }

        public static ActionResult<Receipt> Update(Receipt entity)
        {
            return adapter.Update(entity);
        }

        public static ActionResult<Receipt> Delete(string MaDV)
        {
            return adapter.Delete(MaDV);
        }

        public static ActionResult<Receipt> GetAll()
        {
            return adapter.GetAll();
        }


        public static ActionResult<Receipt> GetSingle(string MaHD)
        {
            return adapter.GetSingle(MaHD);
        }

        public static string NextID()
        {
            return adapter.NextID();
        }

        public static long Total(List<ReceiptDetail> list)
        {
            long t = 0;
            foreach (var item in list)
                t += item.Quantity * item.UnitPrice;
            return t;
        }
    }
}
